CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)

# Set project and language to C++
PROJECT(carblogger_ui "CXX")

# CMake code can be separated into different files called modules. CMake provided
# modules are at CMAKE_MODULE_PATH. Our modules are in ./cmake_modules.
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/ancillary/cmake_modules)

# Use ccache if it is installed.
# FIND_PACKAGE(CCache)
# CCACHE
# OPTION(ENABLE_CCACHE "Enable ccache for compilation" OFF)
# if(ENABLE_CCACHE)
# 	FIND_PACKAGE(CCache REQUIRED)
# 	SET(CCACHE "ccache" CACHE STRING "ccache")
# 	SET(CMAKE_C_COMPILER ${CCACHE} ${CMAKE_C_COMPILER})
# 	SET(CMAKE_CXX_COMPILER ${CCACHE} ${CMAKE_CXX_COMPILER})
# endif()

# BEGIN C++11 feature checks
INCLUDE(CheckCXX11Features)
MESSAGE("-- The following C++ features are required:")

MACRO(require FEATURE_NAME MESSAGE_STRING)
    IF (NOT ${FEATURE_NAME})
        MESSAGE(FATAL_ERROR "\t-- ${MESSAGE_STRING} fail!")
    ELSE()
        MESSAGE("\t-- ${MESSAGE_STRING} ok")
    ENDIF()
ENDMACRO(require)

require(HAS_CXX11_LONG_LONG "C++11 lambdas\t\t\t")
require(HAS_CXX11_AUTO "C++11 auto support:\t\t\t")
require(HAS_CXX11_VARIADIC_TEMPLATES "C++11 variadic templates\t\t")
# ** Uncomment as needed **
# require(HAS_CXX11_NULLPTR "C++11 nullptr support:\t\t")
# require(HAS_CXX11_RVALUE_REFERENCES "C++11 rvalue reference support\t")
# require(HAS_CXX11_CSTDINT_H "C++11 stdint support\t\t\t")
# require(HAS_CXX11_RVALUE_REFERENCES "C++11 rvalue references\t\t")
# require(HAS_CXX11_LONG_LONG "C++11 long long\t\t\t")
# END C++11 feature checks

# BEGIN Default compiler args
IF (NOT CMAKE_BUILD_TYPE)
    MESSAGE("-- Defaulting to release build (use -DCMAKE_BUILD_TYPE:STRING=Debug for debug build)")
    SET(CMAKE_BUILD_TYPE "Release")
ENDIF()

# Append stuff to CMAKE_CXX_FLAGS
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 

# SET(CMAKE_CXX_FLAGS_RELEASE             "-O2 -DNDEBUG -pedantic -Werror -Wall -Wextra -Werror -g")
# TODO Use list append instead.
SET(CMAKE_CXX_FLAGS_RELEASE             "${CMAKE_CXX_FLAGS_RELEASE} -Wno-unused-parameter -Wno-unused-parameter")
SET(CMAKE_CXX_FLAGS_RELEASE             "${CMAKE_CXX_FLAGS_RELEASE} -Wno-error=sign-compare -Wno-error=unused-variable")
SET(CMAKE_CXX_FLAGS_DEBUG               "-O0 -g")
SET(CMAKE_CXX_FLAGS_MINSIZEREL          "-Os -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO	"-O2 -g")
# END Default compiler args

# Using ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/src") instead of # include(CompileSoftware) to hide
# intermediate targets.
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/src")

# Provide a way to quickly test the app (speed up dev time).
INCLUDE(DefineTests) # change to TestSoftware
INCLUDE(PackageSoftware)




# TODO: Set up Doxygen
# # add a target to generate API documentation with Doxygen
# find_package(Doxygen)
# if(DOXYGEN_FOUND)
# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
# add_custom_target(doc
# ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
# COMMENT "Generating API documentation with Doxygen" VERBATIM
# )
# endif(DOXYGEN_FOUND)
